package com.newlink.building.record.mvp

import com.newlink.building.common_base.base.BasePresenter
import com.newlink.building.common_base.ext.ss
import com.newlink.building.common_base.model.bean.RecordMessageReadRequest
import com.newlink.building.record.mvp.contract.Module_Record_CallRecordContract
import com.newlink.building.record.mvp.model.Module_Record_CallRecordModel

/**
 * @author wangyang
 * @date 2022/9/29
 * @description 记录-呼叫记录页面的Presenter
 */
class Module_Record_CallRecordPresenter :
    BasePresenter<Module_Record_CallRecordContract.Model, Module_Record_CallRecordContract.View>(),
    Module_Record_CallRecordContract.Presenter {

    override fun createModel(): Module_Record_CallRecordContract.Model? {
        return Module_Record_CallRecordModel()
    }

    override fun getCallRecordList(
        token: String,
        page: Int,
        limit: Int,
        sip: String,
    ) {
        mModel?.getCallRecordList(token, page, limit, sip)?.ss(mModel, mView) { result ->
            if (result?.data != null) {
                mView?.getCallRecordListSuccess(result.data.total, result.data.list)
            } else {
                mView?.getCallRecordListFail()

            }
        }
    }

    override fun readMissedCalls(token: String, request: RecordMessageReadRequest) {
        mModel?.readMissedCalls(token, request)?.ss(mModel, mView) {
            mView?.readMissedCallsSucess(it?.code == 200)
        }
    }
}